package com.woniuxy.classteacher.mqsend;

import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.UUID;

/**
 * @Auther: 牟强
 * @Date: 2020/8/1/001 14:37
 * @Description: 验证码发送
 */
@Component
public class CodeSend {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    //简单队列发送
    public void send(Object phoneAndCode) {
        //自定义消息的id
        CorrelationData correlationData = new CorrelationData();
        String id = UUID.randomUUID().toString();
        System.out.println("发送id " + id);
        correlationData.setId(id);
        //参数一消息队列的名字    参数2：内容
        rabbitTemplate.convertAndSend("code", phoneAndCode, correlationData);
    }

}
